// pages/mine/paySuccess/paySuccess.js
import constant from "../../../common/constant";
import api from "../../../common/api.js";
import { getDate } from "../../../utils/utilsNew.js";
import * as user from '../../../models/user'
import { gioPaySuccessLog } from "../../../common/gioHandler";
var app = getApp();
let orderPay, orderType, gioUser, gioMobile, gioFromId, gioCity;
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  share(){
    this.onShareAppMessage();
  },
  gotoNewInvite(){
    gioPaySuccessLog(constant.ClickPayBanner, gioFromId, orderType, orderPay, 'invietEntr')
    
    wx.navigateTo({
      url: `/pages/mine/newInvite/newFissionPage/newFissionPage?actEntre=${constant.payBanner}`,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showShareMenu({
      withShareTicket: true,
    });
    orderPay = options.orderPay;
    orderType = options.orderType;
    gioUser = wx.getStorageSync('user');
    gioMobile = app.globalData.sessionUser.extProps.wxMobile || app.globalData.sessionUser.mobile;
    gioFromId = wx.getStorageSync('fromUserId');
    gioCity = wx.getStorageSync('currentCity');

    gioPaySuccessLog(constant.Pay_Sucess, gioFromId, orderType, orderPay)

    let type = options.type;
    let startData = options.startData;
    let endDate = options.endDate;
    this.refreshVip()
    this.setData({
      startData,
      endDate,
      type: 'VIP'+type
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let user = app.globalData.sessionUser.id;
    return {
      imageUrl: getApp().globalData.defaultShareImgUrl,
      title: '兄弟，推房获客黑科技推荐给你！效率高开单多！',
      path: `/pages/index/index?activityCode=MEMBERFISSION&fromUserId=${user}`
    }
  },

  // 更新vip状态
  refreshVip() {
    user.updateVip()
  },

})